from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column
from sqlalchemy import String
from sqlalchemy import TIMESTAMP
from sqlalchemy import Boolean
from sqlalchemy import Integer
from sqlalchemy import text

Base = declarative_base()


class Oplogs(Base):
    __tablename__ = 'oplogs'

    id = Column(Integer, primary_key=True)
    nickname = Column(String(20))
    time = Column(TIMESTAMP,server_default=text('NOW()'))
    op = Column(String(20))
    result = Column(Boolean)

    def __repr__(self):
        return "<Users(nickname='%s',time='%s',op='%s',result=%s)>" % (
            self.nickname, self.time, self.op, self.result)


class Users(Base):
    __tablename__ = 'users'

    nickname = Column(String(20), primary_key=True)
    password = Column(String(20))
    gender = Column(String(5))
    age = Column(Integer)
    is_online = Column(Boolean)

    def __repr__(self):
        return "<Users(nickname='%s',password='%s',gender='%s',age=%s)>" % (
            self.nickname, self.password, self.gender, self.age)
